<template>
	<view class="main">
		<view class="topSelect">
			<view class="topSelect-item" 	@click="timeSelect('dates')">
				<span>日期</span>
				<span class="topSelect-item-icon">
					<u-icon name="arrow-up" color="#757575" size="8"></u-icon>
					<u-icon name="arrow-down" color="#757575" size="8"></u-icon>
				</span>
			</view>
		</view>



		<!--list-satrt -->
		<view class="list">
			<view class="item" v-for="item in dataList" @click="toDetail(item.id)">
				<view class="item-date">
					<span>{{$u.timeFormat(item.dates, 'yyyy')}}</span>
					<view>{{$u.timeFormat(item.dates, 'mm.dd')}}</view>
				</view>
				<view class="item-line"></view>
				<view class="item-title">{{item.name}}</view>
				<!-- <view class="item-dot"></view> -->
			</view>
		</view>
		<!--list-end -->


		<view class="list-end" v-if="dataList.length">{{endText}}</view>

		<u-empty v-if="!dataList.length" mode="car" text="暂无数据" icon="/static/empty-img.png">
		</u-empty>
		
		
		<u-datetime-picker :show="showinTime" :value="inTime" mode="date" closeOnClickOverlay @confirm="TimeConfirm"
			@cancel="TimeClose" @close="inTimeClose"></u-datetime-picker>
		



	</view>
</template>

<script>
	import db from '@/common/localstorage.js'
	export default {
		data() {
			return {
			
				showinTime: false,
				inTime: Number(new Date()),
				timeType: '',
				
				queryParams: {
					flag: 1,
					pageNum: 1,
					pageSize: 10
				},
				total: 0,
				endText: '',
				dataList: []

			}
		},
		onLoad() {

		},
		onShow() {
			this.queryParams.pageNum = 1
			this.dataList = []
			this.getList()
		},
		methods: {
			timeSelect(type) {
				this.timeType = type
				this.showinTime = true
			},
			
			TimeClose() {
				this.showinTime = false
			},
			TimeConfirm(e) {
				this.showinTime = false		
				this.queryParams[this.timeType] =uni.$u.timeFormat(e.value, 'yyyy-mm-dd')
				this.queryParams.pageNum = 1
				this.dataList = []
				this.getList()
			
			},
			getList() {
				this.$modal.msgLoading('加载中')
				var that = this
				
				this.$postjson('/api/RqNotice/list', this.queryParams).then(res => {
					uni.hideLoading()
					if (res.data.code == 200) {
						let detail = res.data.rows
						console.log(detail)
			
						if (detail.length < that.queryParams.pageSize) {
							that.endText = '没有更多了'
						}
						that.total = res.data.total
						that.dataList = that.dataList.concat(detail)
					} else {
						uni.showToast({
							title: res.data.msg,
							icon: 'none'
						})
					}
				})
			},

			toDetail(id) {
				uni.navigateTo({
					url: '/pages/notice/info?id='+id
				})

			},

		},

		onReachBottom: function(e) {
			if (this.total > this.dataList.length) {
				(this.queryParams.pageNum) ++;
				this.getList()
			}
		},
	}
</script>

<style lang="scss" scoped>
	page {
		background: #F9F9F9;
	}
	.topSelect{
		padding:8upx 12upx 28upx 12upx;
		.topSelect-item{
			font-family: PingFangSC, PingFang SC;
			font-weight: 600;
			font-size: 32rpx;
			color: #111111;
			display: flex;
			align-items: center;
		}
		.topSelect-item-icon{
			margin-left: 10upx;
			display: flex;
			flex-direction: column;
		}
	}
	.main {
		padding: 24upx;
		padding-bottom: 260upx;
	}

	.list {
		
		.item{
			margin-bottom: 20upx;
			display: flex;
			align-items: center;
			padding:30upx 20upx;
			width:calc(100% - 40upx);
			background: #FFFFFF;
			border-radius: 10rpx;
			.item-date{
				width: 60rpx;
				height: 60rpx;
				background: linear-gradient( 180deg, #11AA66 0%, #12C66B 100%);
				border-radius: 4rpx;
				font-family: SourceHanSansCN, SourceHanSansCN;
				font-weight: bold;
				font-size: 20rpx;
				color: #FFFFFF;
				text-align: center;
				display: flex;
				align-items: center;
				flex-direction: column;
				justify-content: center;
			}
			.item-line{
				width: 2rpx;
				height: 40rpx;
				background: #E4E4E4;
				margin: 0 20upx;
			}
			.item-title{
				font-family: PingFangSC, PingFang SC;
				font-weight: 500;
				font-size: 32rpx;
				color: #111111;
				margin-right: 20upx;
				width: calc(100% - 60upx - 60upx - 12upx);
				text-overflow: ellipsis;
				overflow: hidden;
				white-space:nowrap;
			}
			.item-dot{
				width: 12rpx;
				height: 12rpx;
				background: #F01022;
				border-radius: 50%;
			}
		}


	}
</style>